package com.lane.sidecn.product.web;

import org.springframework.beans.BeanUtils;

import com.lane.core.web.BaseController;
import com.lane.sidecn.product.model.OrderItem;

/**
 * @author 张先宙 E-mail: zhangxianzhou_std@163.com
 * @version 1.0 创建时间：Jun 30, 2009 10:38:57 PM
 * 
 */

public class OrderItemController extends BaseController {

	private OrderItem orderItem;

	/**
	 * 添加订单项
	 */
	public void add() {
		if (null == orderItem) {
			printMessage("addOrderItemFail");// 添加订单项失败
		}
		try {
			baseManager.save(orderItem);// 保存新的订单项
			printMessage("addOrderItemSuccess");
		} catch (Exception e) {
			printMessage("addOrderItemFail");// 保存失败
		}
	}

	/**
	 * 移除定单项
	 * 
	 */
	public void remove() {
		if (null == orderItem) {
			printMessage("removeOrderItemFail");// 对象为空，删除失败
		}
		try {
			// TODO 通过某一个值找到持久化对象，并将其从数据库中移除
			baseManager.remove(orderItem);
			printMessage("removeOrderItemSuccess");
		} catch (Exception e) {
			printMessage("removeOrderItemFail");// 移除失败
		}
	}

	/**
	 * 
	 * 更新定单项
	 */
	public void update() {
		OrderItem oldItem = find();
		if (null == oldItem) {
			// printMessage("updateOrderItemFail");//TODO 更新失败
		}
		BeanUtils.copyProperties(oldItem, orderItem);
		try {
			baseManager.save(orderItem);// 保存新的订单项
			printMessage("updateOrderItemSuccess");
		} catch (Exception e) {
			printMessage("updateOrderItemFail");// 保存失败
		}

	}

	/**
	 * 查找定单项
	 * 
	 */
	public OrderItem find() {
		// TODO 通过某一个值找到持久化对象
		return null;
	}

	public OrderItem getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(OrderItem orderItem) {
		this.orderItem = orderItem;
	}
}
